<template>
	<view class="box">
		<view class="title">
			<text v-if="item.isDefault==='0'">默认</text>{{addressStr}}
		</view>
		<view class="content">
			<view class="text">{{item.detailedAddress}}</view>
			<view class="icons" @click="toAddressDetail">
				<uni-icons type="location"></uni-icons>
			</view>
		</view>
		<view class="bottom">
			<text>{{item.name}}</text>
			<text>{{item.phone}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		name: "addressItem",
		data() {
			return {
				addressStr: ''
			};
		},
		props: {
			item: {
				type: Object,
				required: true,
			}
		},
		methods: {
			toAddressDetail() {
				wx.navigateTo({
					url: `/subPackages/addressDetail/addressDetail?id=${this.item.id}`
				})
			},
			handleAddress() {
				this.addressStr = this.item.province + '/' + this.item.city + '/' + this.item.district
			}
		},
		created() {
			this.handleAddress()
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		padding: 0 20rpx;

		.title {
			font-size: 20rpx;
			padding: 10rpx 5rpx 0;
			color: #c3c3c3;
			display: flex;
			align-items: center;

			text {
				background-color: #2979ff;
				padding: 5rpx 10rpx;
				color: #fff;
				font-size: 20rpx;
				text-align: center;
				line-height: 30rpx;
				margin-right: 20rpx;
			}
		}

		.content {
			font-size: 28rpx;
			display: flex;
			justify-content: space-around;
			margin-bottom: 5rpx;
			align-items: center;

			.text {
				flex: 1;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				/*! autoprefixer: off */
				-webkit-box-orient: vertical;
			}

			.icons {
				margin: 0 40rpx;
				width: 40rpx;
				height: 40rpx;
				line-height: 40rpx;
				border-radius: 50%;
				background-color: #b6b6b6;
				text-align: center;
			}
		}

		.bottom {
			color: #c3c3c3;
			font-size: 24rpx;
			border-bottom: 2rpx solid #ccc;
			padding-bottom: 20rpx;

			text {
				margin-right: 20rpx;
			}
		}
	}
</style>
